package com.web.new12306.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author 蔡艳
 * Servlet implementation class adminLoginoutServlet
 */
@WebServlet("/adminLoginoutServlet")
public class adminLoginoutServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		 HttpSession session = request.getSession(false);//防止创建Session  
	     if(session == null){    
	         response.sendRedirect(request.getContextPath() + "/adminLogin.jsp");
	         return;  
	     }  	          
	     session.removeAttribute("admin");  
	     response.sendRedirect(request.getContextPath() + "/adminLogin.jsp");
	}

}
